﻿// ----------------------------------------------------------------------------------------
// Author:                    Joaquín López y Magally Vargas
// Company:                   Albalia Interactiva S.L
// Assembly version:          1.0.0.0
// Date:                      10/02/2009
// Time:                      12:11
// Solution Name:             FacturaeAdd-in
// Solution Filename:         FacturaeAdd-in.sln
// Solution FullFilename:     C:\Ribbon_Facturae\FacturaeAdd-in.sln
// Project Name:              FacturaeAdd-in
// Project Filename:          FacturaeAdd-in.csproj
// Project FullFilename:      C:\Ribbon_Facturae\FacturaeAdd-in\FacturaeAdd-in.csproj
// Project Item Name:         ThisAddIn.cs
// Project Item Filename:     ThisAddIn.cs
// Project Item FullFilename: C:\Ribbon_Facturae\FacturaeAdd-in\ThisAddIn.cs
// Project Item Kind:         Código
// Purpose:                   funcionalidad de la aplicación de Office word para el manejo de facturae
//Copyright © 2008 - 2009 Albalia Interactiva S.L. Reservados todos los derechos.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using Word = Microsoft.Office.Interop.Word;
using Office = Microsoft.Office.Core;
using Microsoft.VisualStudio.Tools.Applications.Runtime;
using System.Xml;
using System.Windows.Forms;
using Microsoft.Office.Interop.Word;
using Microsoft.Office.Tools.Word;
using OffInvoiceWordAddIn.XmlMngFiles;
using System.Xml.XPath;
using OffInvoiceWordAddIn.FacturaeFiles;
using System.Xml.Serialization;
using Xades;
using System.IO;
//using System.IO.Packaging;
using System.Globalization;
using OffInvoiceWordAddIn.UBLFiles;

namespace OffInvoiceWordAddIn
{
    public partial class ThisAddIn
    {
        #region "Fields"

        /// <summary>
        /// Variable que referencia al taskpane
        /// </summary>
        Microsoft.Office.Tools.CustomTaskPane taskPane;

        /// <summary>
        /// Atributo de tipo string que referencia al ID del custompart
        /// </summary>
        [CachedAttribute()]
        public string facturaeXMLPartID = string.Empty;

        /// <summary>
        /// Variable que referencia al custompart
        /// </summary>
        private Office.CustomXMLPart facturaXMLPart;

        /// <summary>
        /// Variable de tipo string con el valor de la variable de entorno
        /// </summary>
        public string EnvironmentVariable = "";

        /// <summary>
        /// Variable que referencia al documento
        /// </summary>
        Word.Document document;

        /// <summary>
        /// Variable que referencia al parser que se encarga de manejar los archivos de gestion de facturas
        /// </summary>
        XmlFileMngParser parser;

        /// <summary>
        /// Variable que referencia al ribbon
        /// </summary>
        Ribbon1 ribbon;


        ///// <summary>
        ///// Variable utilizada para cambiar la cultura.
        ///// </summary>
        //public CultureInfo InvoiceCulture;

        /// <summary>
        /// Variable que referencia al taskpane.
        /// </summary>
        InvoiceTaskPane invoicetaskpane;

        /// <summary>
        /// idioma de la aplicacion
        /// </summary>
        String language;

        #endregion

        #region propiedades

        /// <summary>
        /// Propiedad de tipo string que contine el valor del directorio de las plantillas
        /// </summary>
        public string TemplatesDirectories { get; set; }

        #endregion

        #region "Private Methods"

        /// <summary>
        /// Método que se ejecura al iniciar la aplicación, inicializando todo los datos necesarios
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            //InvoiceCulture = CultureInfo.InstalledUICulture;

            //EnvironmentVariable = System.Environment.GetEnvironmentVariable("ProgramFiles");
            EnvironmentVariable = System.Environment.GetEnvironmentVariable("APPDATA");
            parser = new XmlFileMngParser();
            CultureInfo cInfo = new CultureInfo(Globals.ThisAddIn.Application.LanguageSettings.get_LanguageID(Microsoft.Office.Core.MsoAppLanguageID.msoLanguageIDUI));
            language = cInfo.Name;
            TemplatesDirectories = string.Concat(language, @"\");
            try
            {
                //((Ribbon1)Globals.Ribbons.ElementAt(0)).LoadLanguage();
                Globals.Ribbons.Ribbon1.LoadLanguage();
            }
            catch (Exception) { }

           
        }

        /// <summary>
        /// Método que se ejecura al cerrar la aplicación
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
        {

        }

        #endregion

        #region public Methods

        /// <summary>
        /// Método que leer un archivo y devuelve su contenido como un string
        /// </summary>
        /// <param name="pathSignedInvoice">Parámetro de tipo string con el path del archivo</param>
        /// <returns>Un string con el contenido del archivo</returns>
        public string GetXmlFromResource(string pathSignedInvoice)
        {

            using (System.IO.StreamReader resourceReader = new System.IO.StreamReader(pathSignedInvoice))
            {
                if (resourceReader != null)
                {
                    return resourceReader.ReadToEnd();
                }
            }

            return null;
        }

        /// <summary>
        /// Método que añade la facturae como tal como un custompart al documento.
        /// </summary>
        /// <param name="xmlData">Contenido del custompart</param>
        /// <param name="document">Documento al que se le añade</param>
        public void AddCustomXmlPart(string xmlData, Word.Document document)
        {

            if (xmlData != null)
            {
                string id = GetControlValue(ControlList.Tag.customPartId);
                if (id != null)
                    facturaeXMLPartID = id;

                facturaXMLPart = document.CustomXMLParts.SelectByID(facturaeXMLPartID);

                if (facturaXMLPart == null)
                {
                    facturaXMLPart = document.CustomXMLParts.Add(xmlData, missing);
                    facturaeXMLPartID = facturaXMLPart.Id;
                    getControlByTag(ControlList.Tag.customPartId).LockContents = false;
                    setControlValue(ControlList.Tag.customPartId, facturaeXMLPartID);
                    getControlByTag(ControlList.Tag.customPartId).LockContents = true;
                }


            }
        }



        /// <summary>
        /// Método que busca un control por su tag y lo devuelve
        /// </summary>
        /// <param name="tag">Parámetro con el tag del control a buscar</param>
        /// <returns>El ContentControl con el tag especificado por parámetro o null si no se encuentra</returns>
        public Microsoft.Office.Interop.Word.ContentControl getControlByTag(ControlList.Tag tag)
        {
            Microsoft.Office.Interop.Word.ContentControl cc = null;
            try
            {
                foreach (Microsoft.Office.Interop.Word.ContentControl item in Globals.ThisAddIn.Application.ActiveDocument.ContentControls)
                {
                    if (!string.IsNullOrEmpty(item.Tag))
                    {
                        if (item.Tag.ToLower().Equals(tag.ToString("g").ToLower()))
                        {
                            cc = item; break;
                        }

                    }
                }
            }
            catch (Exception) { }
            return cc;
        }

        /// <summary>
        /// Método que busca un control por su tag y lo devuelve
        /// </summary>
        /// <param name="tag">Parámetro con el tag del control a buscar</param>
        /// <returns>El ContentControl con el tag especificado por parámetro o null si no se encuentra</returns>
        public Microsoft.Office.Interop.Word.ContentControl getControlByTag(string tag)
        {
            Microsoft.Office.Interop.Word.ContentControl cc = null;
            try
            {
                foreach (Microsoft.Office.Interop.Word.ContentControl item in Globals.ThisAddIn.Application.ActiveDocument.ContentControls)
                {
                    if (!string.IsNullOrEmpty(item.Tag))
                    {
                        if (item.Tag.ToLower().Equals(tag.ToLower()))
                        {
                            cc = item; break;
                        }

                    }
                }
            }
            catch (Exception) { }
            return cc;
        }

        /// <summary>
        /// Método que abre el taskpane
        /// </summary>
        /// <param name="r"></param>
        public void OpenInvoiceTaskPane(Ribbon1 r, bool first)
        {
            if (first)
            {
                Language l = Language.getInstance();
                ribbon = r;
                invoicetaskpane = new InvoiceTaskPane();
                taskPane = this.CustomTaskPanes.Add(invoicetaskpane, l.getLabels("lbMyInvoices"));
                taskPane.Width = 370;
                taskPane.Visible = true;
            }
            else
            {
                taskPane.Visible = true;
            }


        }

        /// <summary>
        /// Método que elimina el taskane
        /// </summary>
        public void RemoveInvoiceTaskPane()
        {
            //this.CustomTaskPanes.Remove(taskPane);
            this.taskPane.Visible = false;
            //invoicetaskpane = null;
        }

        /// <summary>
        /// Método que actualiza el contenido del taskpane
        /// </summary>
        public void updateTaskPane()
        {
            if (invoicetaskpane != null)
            {
                invoicetaskpane.updateTaskPane();
            }

        }


        /// <summary>
        /// Método que abre un docx.
        /// </summary>
        /// <param name="temp"></param>
        public void OpenDocx(object temp)
        {
            object template = temp;
            object oMissing = System.Reflection.Missing.Value;
            object doNotSaveChanges = Microsoft.Office.Interop.Word.WdSaveOptions.wdDoNotSaveChanges;

            Globals.ThisAddIn.Application.ActiveDocument.Close(ref doNotSaveChanges, ref oMissing, ref oMissing);

            Globals.ThisAddIn.Application.Documents.Add(ref template, ref oMissing, ref oMissing, ref oMissing);

        }

        /// <summary>
        /// Método que guarda un registro de una factura en la bitacora 
        /// </summary>
        /// <param name="year">Parámetro de tipo string con el año</param>
        /// <param name="month">Parámetro de tipo string con el mes</param>
        /// <param name="status">Parámetro de tipo string con el estado</param>
        /// <param name="invoice">Parametro de tipo XmlInvoice con los datos de la factura</param>
        public void save(string year, string month, string status, XmlInvoice invoice)
        {
            try
            {
                parser.addNewXmlInvoiceRecord(year, month, status, invoice);
            }
            catch (Exception e)
            {
                ControlMessages controlM = ControlMessages.getInstance();
                MessageBox.Show(controlM.getMessage(e.Message), controlM.getMessage(ControlMessages.Msg.CaptionFacturae), MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
            }


        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="schemaUrl"></param>
        /// <param name="schemaNamespaceUri"></param>
        /// <param name="schemaAlias"></param>
        public void AttachCustomXmlSchema(string schemaUrl, string schemaNamespaceUri, string schemaAlias)
        {
            try
            {
                object schemaNamespaceUriObj = schemaNamespaceUri;
                object schemaAliasObj = schemaAlias;
                Word.XMLNamespace customXmlNamespace = null;
                try
                {
                    customXmlNamespace = Globals.ThisAddIn.Application.XMLNamespaces.get_Item(ref schemaNamespaceUriObj);
                }
                catch { };
                if (customXmlNamespace == null)
                {
                    customXmlNamespace = Globals.ThisAddIn.Application.XMLNamespaces.Add(schemaUrl, ref schemaNamespaceUriObj, ref schemaAliasObj, true);
                }
                object documentObj = Globals.ThisAddIn.Application.ActiveDocument;
                customXmlNamespace.AttachToDocument(ref documentObj);
            }
            catch (Exception)
            {

            }
        }

        /// <summary>
        /// Método que devuelve el valor de un control cuyo tag es el que se pasa por parámetro.
        /// </summary>
        /// <param name="tag">Parámetro de tipo string con el tag del control a buscar</param>
        /// <returns>Un string con el valor del control</returns>
        public string GetControlValue(ControlList.Tag tag)
        {
            string Value = "";
            try
            {
                foreach (Microsoft.Office.Interop.Word.ContentControl item in Globals.ThisAddIn.Application.ActiveDocument.ContentControls)
                {
                    if (!string.IsNullOrEmpty(item.Tag))
                    {
                        if (item.Tag.ToLower().Equals(tag.ToString("g").ToLower()))
                        {

                            Value = item.Range.Text.Trim();
                            break;
                        }

                    }
                }
            }
            catch (Exception) { return Value; }
            return Value;
        }


        /// <summary>
        /// Método que bloquea todos los controles del documento.
        /// </summary>
        public void ProtectDocument()
        {
            if (document == null)
                document = Globals.ThisAddIn.Application.ActiveDocument;


            try
            {
                foreach (Microsoft.Office.Interop.Word.ContentControl item in document.ContentControls)
                {
                    item.LockContentControl = true;
                    item.LockContents = true;
                }


            }
            catch (Exception) { }

        }

        /// <summary>
        /// Método que carga los datos del emisor
        /// </summary>
        /// <param name="configData">Parámetro de tipo ConfigData referenciando a la configuración definida por el usuario</param>
        public void LoadIssuerData(ConfigData configData)
        {

            try
            {


                setControlValue(ControlList.Tag.SP_PersonTypeCode, configData.PersonType);
                if (configData.PersonTypeCode.Equals("J"))
                {
                    setControlValue(ControlList.Tag.SP_CorporateName, configData.CompanyName);
                }
                else
                {
                    setControlValue(ControlList.Tag.SP_Name, configData.Name);
                    setControlValue(ControlList.Tag.SP_FirstSurname, configData.FirstName);
                    setControlValue(ControlList.Tag.SP_SecondSurname, configData.SecondName);
                }
                setControlValue(ControlList.Tag.SP_ResidenceTypeCode, configData.ResidenceType);
                setControlValue(ControlList.Tag.SP_TaxIdentificationNumber, configData.CIF);
                setControlValue(ControlList.Tag.SP_CountryCode, configData.Country);
                setControlValue(ControlList.Tag.SP_Province, configData.State);
                setControlValue(ControlList.Tag.SP_Address, configData.Address);
                setControlValue(ControlList.Tag.SP_Telephone, configData.Telephone);
                setControlValue(ControlList.Tag.SP_PostCode, configData.CP);
                setControlValue(ControlList.Tag.SP_Town, configData.County);
                setControlValue(ControlList.Tag.SP_email, configData.Email);


            }
            catch (Exception) { }



        }



        /// <summary>
        /// Método que asigna al control cuyo tag se recibe por parámetro el valor que se recibe por parámetro
        /// </summary>
        /// <param name="tag">Parámetro con el tag del control a asignar el valor</param>
        /// <param name="value">Parámetro de tipo string con el valor</param>
        public void setControlValue(ControlList.Tag tag, string value)
        {

            try
            {
                foreach (Microsoft.Office.Interop.Word.ContentControl item in Globals.ThisAddIn.Application.ActiveDocument.ContentControls)
                {
                    if (!string.IsNullOrEmpty(item.Tag))
                    {
                        if (item.Tag.ToLower().Equals(tag.ToString("g").ToLower()))
                        {
                            item.Range.Text = value;
                            break;
                        }

                    }
                }
            }
            catch (Exception) { }
        }


        /// <summary>
        /// Método que actualiza los checkbox de estado
        /// </summary>
        /// <param name="ckBoxIssued">Parámetro de tipo bool con el valor del check de emitida</param>
        /// <param name="ckBoxReceived">Parámetro de tipo bool con el valor del check de recibida</param>
        /// <param name="ckBoxDraft">Parámetro de tipo bool con el valor del check de borraror</param>
        /// <param name="status">Parámetro de tipo string con el valor del estado</param>
        public void updateStatusCheck(bool ckBoxIssued, bool ckBoxReceived, bool ckBoxDraft, string status)
        {
            ribbon.getCkBoxIssued().Checked = ckBoxIssued;
            ribbon.getCkBoxReceived().Checked = ckBoxReceived;
            ribbon.getCkBoxDraft().Checked = ckBoxDraft;
            ribbon.setStatus(status);
        }


        /// <summary>
        /// Método que cargar el combobox de los paises.
        /// </summary>
        public void LoadCountryComboBox()
        {

            string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\Microsoft OffInvoice\InformationFiles\" + language + @"\Countries.txt";

            string[] data = { "Afganistán", "AFG", "Albania", "ALB", "Alemania", "DEU", "Andorra", "AND", "Angola", "AGO", "Anguilla", "AIA", "Antigua y Barbuda", "ATG", "Antillas Holandesas", "ANT", "Arabia Saudí", "SAU", "Argelia", "DZA", "Argentina", "ARG", "Armenia", "ARM", "Aruba", "ABW", "ARY Macedonia", "MKD", "Australia", "AUS", "Austria", "AUT", "Azerbaiyán", "AZE", "Bahamas", "BHS", "Bahréin", "BHR", "Bangladesh", "BGD", "Barbados", "BRB", "Bélgica", "BEL", "Belice", "BLZ", "Benin", "BEN", "Bermudas", "BMU", "Bhután", "BTN", "Bielorrusia", "BLR", "Bolivia", "BOL", "Bosnia y Herzegovina", "BIH", "Botsuana", "BWA", "Brasil", "BRA", "Brunéi", "BRN", "Bulgaria", "BGR", "Burkina Faso", "BFA", "Burundi", "BDI", "Cabo Verde", "CPV", "Camboya", "KHM", "Camerún", "CMR", "Canadá", "CAN", "Chad", "TCD", "Chile", "CHL", "China", "CHN", "Chipre", "CYP", "Ciudad del Vaticano", "VAT", "Colombia", "COL", "Comoras", "COM", "Congo", "COG", "Corea del Norte", "PRK", "Corea del Sur", "KOR", "Costa de Marfil", "CIV", "Costa Rica", "CRI", "Croacia", "HRV", "Cuba", "CUB", "Dinamarca", "DNK", "Dominica", "DMA", "Ecuador", "ECU", "Egipto", "EGY", "El Salvador", "SLV", "Emiratos Árabes Unidos", "ARE", "Eritrea", "ERI", "Eslovaquia", "SVK", "Eslovenia", "SVN", "España", "ESP", "Estados Unidos", "USA", "Estonia", "EST", "Etiopía", "ETH", "Filipinas", "PHL", "Finlandia", "FIN", "Fiyi", "FJI", "Francia", "FRA", "Gabón", "GAB", "Gambia", "GMB", "Georgia", "GEO", "Ghana", "GHA", "Gibraltar", "GIB", "Granada", "GRD", "Grecia", "GRC", "Groenlandia", "GRL", "Guadalupe", "GLP", "Guam", "GUM", "Guatemala", "GTM", "Guayana Francesa", "GUF", "Guernsey", "GGY", "Guinea", "GIN", "Guinea Ecuatorial", "GNQ", "Guinea-Bissau", "GNB", "Guyana", "GUY", "Haití", "HTI", "Honduras", "HND", "Hong Kong", "HKG", "Hungría", "HUN", "India", "IND", "Indonesia", "IDN", "Irán", "IRN", "Iraq", "IRQ", "Irlanda", "IRL", "Isla de Man", "IMN", "Isla Norfolk", "NFK", "Islandia", "ISL", "Islas Caimán", "CYM", "Islas Cook", "COK", "Islas Feroe", "FRO", "Islas Malvinas", "FLK", "Islas Marianas del Norte", "MNP", "Islas Marshall", "MHL", "Islas Pitcairn", "PCN", "Islas Salomón", "SLB", "Islas Turcas y Caicos", "TCA", "Islas Vírgenes Británicas", "VGB", "Islas Vírgenes de los Estados Unidos", "VIR", "Israel", "ISR", "Italia", "ITA", "Jamaica", "JAM", "Japón", "JPN", "Jersey", "JEY", "Jordania", "JOR", "Kazajstán", "KAZ", "Kenia", "KEN", "Kirguistán", "KGZ", "Kiribati", "KIR", "Kuwait", "KWT", "Laos", "LAO", "Lesotho", "LSO", "Letonia", "LVA", "Líbano", "LBN", "Liberia", "LBR", "Libia", "LBY", "Liechtenstein", "LIE", "Lituania", "LTU", "Luxemburgo", "LUX", "Macao", "MAC", "Madagascar", "MDG", "Malasia", "MYS", "Malawi", "MWI", "Maldivas", "MDV", "Malí", "MLI", "Malta", "MLT", "Marruecos", "MAR", "Martinica", "MTQ", "Mauricio", "MUS", "Mauritania", "MRT", "Mayotte", "MYT", "México", "MEX", "Micronesia", "FSM", "Moldavia", "MDA", "Mónaco", "MCO", "Mongolia", "MNG", "Montenegro", "MNE", "Montserrat", "MSR", "Mozambique", "MOZ", "Myanmar", "MMR", "Namibia", "NAM", "Nauru", "NRU", "Nepal", "NPL", "Nicaragua", "NIC", "Níger", "NER", "Nigeria", "NGA", "Niue", "NIU", "Noruega", "NOR", "Nueva Caledonia", "NCL", "Nueva Zelanda", "NZL", "Omán", "OMN", "Países Bajos", "NLD", "Pakistán", "PAK", "Palau", "PLW", "Palestina", "PSE", "Panamá", "PAN", "Papúa Nueva Guinea", "PNG", "Paraguay", "PRY", "Perú", "PER", "Polinesia Francesa", "PYF", "Polonia", "POL", "Portugal", "PRT", "Puerto Rico", "PRI", "Qatar", "QAT", "Reino Unido", "GBR", "República Centroafricana", "CAF", "República Checa", "CZE", "República Democrática del Congo", "COD", "República Dominicana", "DOM", "Reunión", "REU", "Ruanda", "RWA", "Rumania", "ROU", "Rusia", "RUS", "Sahara Occidental", "ESH", "Samoa", "WSM", "Samoa Americana", "ASM", "San Cristóbal y Nevis", "KNA", "San Marino", "SMR", "San Pedro y Miquelón", "SPM", "San Vicente y las Granadinas", "VCT", "Santa Helena", "SHN", "Santa Lucía", "LCA", "Santo Tomé y Príncipe", "STP", "Senegal", "SEN", "Serbia", "SRB", "Seychelles", "SYC", "Sierra Leona", "SLE", "Singapur", "SGP", "Siria", "SYR", "Somalia", "SOM", "Sri Lanka", "LKA", "Suazilandia", "SWZ", "Sudáfrica", "ZAF", "Sudán", "SDN", "Suecia", "SWE", "Suiza", "CHE", "Surinam", "SUR", "Svalbard y Jan Mayen", "SJM", "Tailandia", "THA", "Taiwán", "TWN", "Tanzania", "TZA", "Tayikistán", "TJK", "Timor Oriental", "TLS", "Togo", "TGO", "Tokelau", "TKL", "Tonga", "TON", "Trinidad y Tobago", "TTO", "Túnez", "TUN", "Turkmenistán", "TKM", "Turquía", "TUR", "Tuvalu", "TUV", "Ucrania", "UKR", "Uganda", "UGA", "Uruguay", "URY", "Uzbekistán", "UZB", "Vanuatu", "VUT", "Venezuela", "VEN", "Vietnam", "VNM", "Wallis y Futuna", "WLF", "Yemen", "YEM", "Yibuti", "DJI", "Zaire", "ZAR", "Zambia", "ZMB", "Zimbabue", "ZWE" };

            string datos = ReadFile(path);

            if (!string.IsNullOrEmpty(datos))
            {
                data = datos.Replace("\r\n", "\t").Trim().Split('\t');
            }

            try
            {
                int index = 0;

                getControlByTag(ControlList.Tag.SP_CountryCode).DropdownListEntries.Clear();
                getControlByTag(ControlList.Tag.BP_CountryCode).DropdownListEntries.Clear();

                for (int i = 0; i < data.Length; i++)
                {
                    getControlByTag(ControlList.Tag.SP_CountryCode).DropdownListEntries.Add(data[i], data[i + 1], index);
                    getControlByTag(ControlList.Tag.BP_CountryCode).DropdownListEntries.Add(data[i], data[i + 1], index);

                    i++; index++;
                }


            }
            catch (Exception) { }

            try
            {

                int index = 0;

                getControlByTag(ControlList.Tag.TH_CountryCode).DropdownListEntries.Clear();

                for (int i = 0; i < data.Length; i++)
                {
                    getControlByTag(ControlList.Tag.TH_CountryCode).DropdownListEntries.Add(data[i], data[i + 1], index);
                    i++; index++;
                }

            }
            catch (Exception)
            {

            }
        }


        /// <summary>
        /// Método que actualiza los checkbox de estado
        /// </summary>
        /// <param name="issued">Parámetro de tipo bool con el valor del check de emitida</param>
        /// <param name="received">Parámetro de tipo bool con el valor del check de recibida</param>
        /// <param name="draft">Parámetro de tipo bool con el valor del check de borraror</param>
        public void updateStatus(bool issued, bool received, bool draft)
        {
            this.ribbon.ckBoxIssued.Checked = issued;
            this.ribbon.ckBoxReceived.Checked = received;
            this.ribbon.ckBoxDraft.Checked = draft;
        }

        public string ReadFile(string path)
        {
            try
            {
                using (StreamReader sr = new StreamReader(path, Encoding.Default))
                {
                    return sr.ReadToEnd();
                }
            }
            catch (Exception) { return ""; }
        }
        #endregion
        #region VSTO generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InternalStartup()
        {
            this.Startup += new System.EventHandler(ThisAddIn_Startup);
            this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
        }

        #endregion


    }
}
